package com.adv.ems.controller.admin;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.BaseQueryParam;
import com.adv.ems.model.vo.BaseItemVO;
import com.adv.ems.model.vo.BaseOneItemVO;
import com.adv.ems.model.vo.BaseTwoItemVO;
import com.adv.ems.service.BaseDataService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/base/item")
public class ItemController {
    @Resource
    BaseDataService baseDataService;

    @PostMapping("/list")
    public APIResponse<BaseItemVO> list(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                              @RequestBody APIRequest<BaseQueryParam> request) {
        return APIResponse.<BaseItemVO>build().content(baseDataService.list(request.getContent(), acceptLanguage));
    }

    @PostMapping("/one/list")
    public APIResponse<BaseOneItemVO> oneList(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                              @RequestBody APIRequest<BaseQueryParam> request) {
        return APIResponse.<BaseOneItemVO>build().content(baseDataService.oneList(request.getContent(), acceptLanguage));
    }

    @PostMapping("/two/list")
    public APIResponse<BaseTwoItemVO> twoList(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                              @RequestBody APIRequest<BaseQueryParam> request) {
        return APIResponse.<BaseTwoItemVO>build().content(baseDataService.twoList(request.getContent(), acceptLanguage));
    }
}
